<template>
  <el-row :gutter="16">
    <el-col
      :xs="24"
      :sm="12"
      :md="12"
      :lg="6"
      :xl="6"
      v-for="item in growCardList"
      :key="item.title"
    >
      <el-card shadow="never">
        <template #header>
          <div class="card-header">
            <span class="title">{{ item.title }}</span>
            <el-tag :type="item.color">{{ item.action }}</el-tag>
          </div>
        </template>

        <div class="card-header">
          <CountTo prefix="$" :startVal="0" :endVal="item.value" class="count" />
          <el-icon color="#888" style="font-size: 40px" class="icon">
            <component :is="item.icon" />
          </el-icon>
        </div>

        <div class="card-header card-footer">
          <span>总{{ item.title }}</span>
          <CountTo prefix="$" :startVal="0" :endVal="item.total" />
        </div>
      </el-card>
    </el-col>
  </el-row>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { CountTo } from '@/components/CountTo/index'
import { growCardList } from '../../data'

export default defineComponent({
  name: 'GrowCard',
  components: {
    CountTo
  },
  setup() {
    return {
      growCardList
    }
  }
})
</script>

<style lang="scss" scoped>
::v-deep(.el-card__header) {
  padding: 8px 12px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  .title {
    font-size: 14px;
    font-weight: normal;
  }
}

.count {
  font-size: 2rem;
  line-height: 2rem;
}

.card-footer {
  font-size: 14px;
  padding-top: 20px;
}
</style>
